<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>动画原理</title>
  <script src="vue.js"></script>
  <style>
    .fade-enter,.fade-leave{
      opacity: 0;
    }
    .fade-enter-active,.fade-leave-active{
      transition: opacity 3s;
    }
  </style>
</head>
<body>
<!--transition标签是必须的-->
<!--想实现动画的DOM元素之外加一个transition标签即可-->
<!--transition里的name属性没有时  fade-enter就会变为v-enter;  v是Vue默认的前缀-->
<div id="app">
  <transition name="fade">
    <div v-show="show">hello world</div>
  </transition>
  <button @click="handelBtnClick">change</button>
</div>
<script>
  var vm=new Vue({
    el:"#app",
    data:{
      show:true,
    },
    methods:{
      handelBtnClick:function(){
        this.show=!this.show
      }
    }
  })
</script>
</body>
</html>
